import Layout from '../pages/Layout'
import Login from '../pages/Login'
// import Home from '../pages/Home'
// import Article from '../pages/Article'
// import Publish from '../pages/Publish'

import { lazy, Suspense } from 'react'
// 对路由函数进行导入
const Publish = lazy(() => import('../pages/Publish'))
const Article = lazy(() => import('../pages/Article'))
const Home = lazy(() => import('@/pages/Home'))

import { createBrowserRouter } from 'react-router-dom'
import { AuthRoute } from '../components/AuthRouter.jsx'

const router = createBrowserRouter([
    {
        path: "/",
        element: <AuthRoute><Layout></Layout></AuthRoute>,
        children: [
            {
                path: "/",
                element: (<Suspense fallback={'加载中...'}> <Home /></Suspense>)
            },
            {
                path: "article",
                element: (
                    <Suspense fallback={'加载中'}>
                        <Article />
                    </Suspense>
                )
            },
            {
                path: "publish",
                element: (
                    <Suspense fallback={'加载中'}>
                        <Publish />
                    </Suspense>
                )
            },
        ]
    },
    {
        path: "/login",
        element: <Login></Login>
    },
])

export default router